from django.shortcuts import render
from django.views.generic import View
from django.http import HttpResponse
from django.middleware.common import CommonMiddleware
from django.core.exceptions import PermissionDenied
from django.contrib.messages.middleware import MessageMiddleware

"""
1.通用中间件：django.middleware.common.CommonMiddleware
1.1 限制settings.DISALLOWED_USER_AGENTS中指定的请求头来访问本网站。DISALLOWED_USER_AGENT是一个正则表达式的列表。
1.2 如果开发者在定义url的时候，最后有一个斜杠。但是用户在访问url的时候没有提交这个斜杠，那么CommonMiddleware会自动的重定向到加了斜杠的url上去
"""


class IndexView(View):
    def get(self, request, *args, **kwargs):
        return HttpResponse('首页')


class SigninView(View):
    def get(self, request, *args, **kwargs):
        return render(request, 'signin.html')